package cn.test.file;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

/**
 * @ClassName ArrayListFile
 * @Description TODO
 * @Author User
 * @Date 2020/12/14 11:31
 * @Version 1.0
 */
public class ArrayListFile {
    public static void main(String[] args) throws IOException {
        ArrayList<String> array = new ArrayList<>();
        array.add("你好，世界");
        array.add("hello，world");
        array.add("hello，java");
        array.add("hello，file");

        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("file\\array.txt"));

        for(String str:array){
            bufferedWriter.write(str);
            bufferedWriter.newLine();
            bufferedWriter.flush();
        }

        bufferedWriter.close();
    }
}
